﻿package com.mod  {

    import com.calefk.core.Page;
	import com.calefk.core.PageManager;
    import com.calefk.core.PageName;
	import com.mod.page.CreditPage;
	import com.mod.page.GamePage;
	import com.mod.page.HelpPage;
	import com.mod.page.MenuPage;
	import com.mod.page.OverPage;
	import com.mod.page.WinPage;
	import flash.display.MovieClip;
	import flash.utils.*;
    
	/**
	 * Clase donde aloja todos las paginas que usará la aplicación.
     * Instancia una pagina y le asigna el clip a usar.
	 */
    
	public class PMGame extends PageManager {
		
        public static const PAGE_MENU:PageName = addPN(MenuPage , "mcMenuPage");
		public static const PAGE_GAME:PageName = addPN(GamePage , "mcGamePage"); 
		public static const PAGE_OVER:PageName = addPN(OverPage , "mcOverPage"); 
		public static const PAGE_WIN  :PageName = addPN(WinPage , "mcWinPage");	
		public static const PAGE_CREDITS  :PageName = addPN(CreditPage , "mcCreditPage");	
		public static const PAGE_HELP:PageName = addPN(HelpPage, "mcHelpPage");
        private static function addPN(className:Class , clipName:String):PageName {
            return PageManager.addPN(className , clipName);
        }
		
		public function PMGame(canvas:MovieClip) {
			super(canvas);
		}
        
        public function get currentPage():Page {
            return mCurrentPage;
        }
		
		override public function gotoPage(pageName:PageName):void {
            
            // hago super para borrar la pagina en memoria
			super.gotoPage(null);
            
            // lo hago de esta forma para que las clases no sean de tipo String y sea reconocible para el ofuscador.
            var classPage:Class = pageName.className;
            mCurrentPage = new classPage(mCanvasObjects, pageName.clipName);
            
			/*switch (idMovieClip) {
				case PAGE_MENU: 
					mCurrentPage = new MenuPage(mCanvasObjects , idMovieClip); 
					break;
				case PAGE_GAME: 
					mCurrentPage = new GamePage(mCanvasObjects , idMovieClip);  
					break;
				case PAGE_OVER: 
					mCurrentPage = new OverPage(mCanvasObjects , idMovieClip);  
					break;
				case PAGE_START: 
					mCurrentPage = new StartPage(mCanvasObjects , idMovieClip);  
					break;                    
			}*/
		}
	}
}